import { Byte } from '../../api/io/Byte';
import { HashMap } from '../../api/struct/HashMap';


export const enum E_CDLegionCrusade {
	/**ID*/
	id,
	/**讨伐ID*/
	stageId,
	/**名字*/
	name,
	/**描述*/
	desc,
	/**讨伐时间（这个到时候放在stage表里吧）*/
	crusadeTime,

	/**枚举数量*/
	EnumCount
}



export class CDLegionCrusade{
	/**ID*/
	public id: number;
	/**讨伐ID*/
	public stageId: number;
	/**名字*/
	public name: number;
	/**描述*/
	public desc: number;
	/**讨伐时间（这个到时候放在stage表里吧）*/
	public crusadeTime: number;


	/**获取属性值*/
	public getAttr(idx: number): any {
		switch(idx) { 
			default: return;
			case E_CDLegionCrusade.id: return this.id;
			case E_CDLegionCrusade.stageId: return this.stageId;
			case E_CDLegionCrusade.name: return this.name;
			case E_CDLegionCrusade.desc: return this.desc;
			case E_CDLegionCrusade.crusadeTime: return this.crusadeTime;
		}
	}



	/**设置属性值*/
	public setAttr(idx: number, v: any): void {
		switch(idx) { 
			default: break;
			case E_CDLegionCrusade.id: this.id = v; break;
			case E_CDLegionCrusade.stageId: this.stageId = v; break;
			case E_CDLegionCrusade.name: this.name = v; break;
			case E_CDLegionCrusade.desc: this.desc = v; break;
			case E_CDLegionCrusade.crusadeTime: this.crusadeTime = v; break;
		}
	}


	/**数据*/
	public static datas: HashMap<number, CDLegionCrusade> = new HashMap<number, CDLegionCrusade>();



	/**加载数据*/
	public static load(byte: Byte): void{
		const size = byte.readInt32();
		const list : CDLegionCrusade[] = [];
		let i :number;

		for (i = 0; i < size; i++) {
			list[i] = new CDLegionCrusade();
		}
		for (i = 0; i < size; i++) {
			list[i].id = byte.readInt32();
			this.datas.put(list[i].id, list[i]);
		}
		for (i = 0; i < size; i++) {
			list[i].stageId = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].name = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].desc = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].crusadeTime = byte.readInt32();
		}
	}


	/** 获取数据*/
	public static getData(id: number): CDLegionCrusade{
		return this.datas ? this.datas.get(id) : null;
	}
}
